/*
 * @Author: lcx
 * @Date: 2023-09-15 15:33:25
 * @LastEditors: 王文豪
 * @LastEditTime: 2023-12-17 15:58:06
 * @FilePath: \gw-pub-website-jiangxi\src\main.js
 * 
 */
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'default-passive-events'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
import api from "@/api/api";
Vue.config.productionTip = false
Vue.prototype.$api = api
import moment from "moment";
import TreeSelect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
Vue.component('TreeSelect',TreeSelect)
import VueRouter from "vue-router";
let originPush =  VueRouter.prototype.push;  //备份原push方法

import verify from "@/api/verify.js"
Vue.prototype.verifyfilter = verify.filter
VueRouter.prototype.push = function (location, resolve, reject){
  if (resolve && reject) {    //如果传了回调函数，直接使用
    originPush.call(this, location, resolve, reject);
  }else {                     //如果没有传回调函数，手动添加
    originPush.call(this, location, ()=>{}, ()=>{});
  }
}
Vue.filter('clearEditor', function (value) {
  if (!value) return ''
  value = value.toString().replace(/<[^>]+>|&[^>]+;/g, "")
  return value
})
Vue.filter('repC',function(value,search) {
  if (!value) return ''
  value = value.toString().replace(/<[^>]+>|&[^>]+;/g, "")
  if (value.length > 550) {
    value = value.slice(0, 550) + "...";
  }
  if (value && value.length > 0) {
    const reg = `/${search}/g`;
    value = value.replace(
        eval(reg),
        "<span style='color: red;'>" + search + "</span>"
    );
  }
  return value
  //return null
})
Vue.filter('subStr',function(value,length) {
  if (!value) return ''
  value = value.toString().replace(/<[^>]+>|&[^>]+;/g, "")
  if (value.length > length) {
    value = value.slice(0, length) + "...";
  }
  return value
  //return null
})

Vue.filter('timeFormateYYYYMMDD', function (value) {
  return moment(value).format('YYYY-MM-DD HH:mm:ss')
})
Vue.filter('timeFormateDD', function (value) {
  return moment(value).format('DD')
})
Vue.filter('timeFormateYYYYMM', function (value) {
  return moment(value).format('YYYY/MM')
})
Vue.filter('timeFormateYMD', function (value) {
  return moment(value).format('YYYY-MM-DD')
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
